/******************************************************************************
**
**  COPYRIGHT (C) 2006 Marvell Corporation.
**
**  FILENAME:  xllp_lcd_lt_topoly.c
**
**  PURPOSE:   platform-specific source file for XLLP LCD controller.
**  			  This file is specific for Topoly(QVGA/VGA) on Liltteton
**
*******************************************************************************/

#include "windows.h"
#include "ceddk.h"

#include "monahans_base_regs.h"

#include "xllp_lcd.h"
#include "xllp_lcd_cpu.h"
#include "xllp_lcd_plat.h"
#include "xllp_mfp.h"
#include "xllp_gpio_proc.h"
#include "xllp_clkmgr.h"
#include "xllp_mfp_plat.h"
#include "xllp_ssp_peri.h"
#include "xllp_ssp_plat.h"
#include "xllp_i2c_proc.h"
#include "xllp_gpio_plat.h"
#include "xllp_clkmgr.h"

#include "xllp_ost.h"
static void set_power_mode(struct XLLP_LCD_S *pXllpLCD, XLLP_UINT32_T power_mode);
static XLLP_STATUS_T init_pins(P_XLLP_LCD_T pXllpLCD);
static XLLP_STATUS_T mini_lcd_init_pins(P_XLLP_MINI_LCD_T pXllpMiniLCD, int is_on);
XLLP_STATUS_T configure_L38GM9360_lcd(struct XLLP_LCD_S* pXllpLCD);

void lcd_panel_reset(XLLP_SSP_REGISTER_T *ssp);
void vga_pass_through_mode(XLLP_SSP_REGISTER_T *ssp);
void qvga_pass_through_mode(XLLP_SSP_REGISTER_T *ssp);
void qvga_ram_write_mode(XLLP_SSP_REGISTER_T *ssp);
void vga_transfer_config(XLLP_SSP_REGISTER_T *ssp);
void qvga_transfer_config(XLLP_SSP_REGISTER_T *ssp);
void qvga_osc_config(XLLP_SSP_REGISTER_T *ssp);
void lcd_panel_config(XLLP_SSP_REGISTER_T *ssp);
extern XLLP_STATUS_T XllpI2cInit(P_XLLP_I2C_T I2C_regs, P_XLLP_VUINT32_T pMfpRegBase, P_XLLP_MFP_RM_DB_ID_T pMfpRmDb, XLLP_UINT32_T dev_id) ;
extern XLLP_STATUS_T XllpGpioExpanderSetOutputLevel(XLLP_I2C_T *pI2CReg, XLLP_OST_T *pOSTReg, XLLP_UINT32_T gpioId,	 XLLP_LEVEL_T level);


#define WIDTH_VGA 480
#define HEIGHT_VGA 640

#define WIDTH_QVGA 240
#define HEIGHT_QVGA 320

#define WIDTH_WVGA 480
#define HEIGHT_WVGA 800
static P_XLLP_LCD_T p_lcd=NULL;

static tft_panel_t wvga_L38GM9360_topoly =
{
	LCD_TFT,
	WIDTH_WVGA,
	HEIGHT_WVGA,
    set_power_mode,
	init_pins,
	mini_lcd_init_pins,
	configure_L38GM9360_lcd,
	// timing: min PCLK=6.5Mhz, PCD=ACCR[HSS]/PCLK -1

	{
		10,//2//7,	/* BLW */
		10,//2//87,	/* ELW */
		10,//1//7,	/* HSW */
		8,//2//3,	/* BFW */
		8,//2//1,	/* EFW */
		8,//1//1,	/* VSW */
		/* PCD */
		{
			0x3,      /* 104M */
			0x5,    /* 156M */
			0x7,    /* 208M */
			0x0,      /* 39M */
			0x0       /* D0CS = 60M,PCLK = 6.8M */
		}
	},

	{
		0,//0: active HI 1:active LOW	/* OEP */
		0,//0: rising 1: falling	/* PCP */
		1,//1//0: active HI 1:active LOW,	/* HSP */
		1,//1//0: active HI 1:active LOW	/* VSP */
	}
};
static tft_panel_t qvga_topoly = 
{
	LCD_TFT,
	WIDTH_QVGA,
	HEIGHT_QVGA,
       set_power_mode,
	init_pins,
	mini_lcd_init_pins,
	configure_L38GM9360_lcd,
	// timing: min PCLK=6.5Mhz, PCD=ACCR[HSS]/PCLK -1
	{
		2,//7,	/* BLW */
		2,//87,	/* ELW */
		1,//7,	/* HSW */
		2,//3,	/* BFW */
		2,//1,	/* EFW */
		1
		,//1,	/* VSW */
		/* PCD */
		{
			0xE,      /* 104M */
			0x16,    /* 156M */
			0x1E,    /* 208M */
			0x5,      /* 39M */
			0x8       /* D0CS = 60M,PCLK = 6.8M */
		}
	},
	{
		0,	/* OEP */
		0,	/* PCP */
		1,	/* HSP */
		1	/* VSP */
	}
};

static tft_panel_t vga_topoly = 
{
	LCD_TFT,
	WIDTH_VGA,
	HEIGHT_VGA,
       set_power_mode,
	init_pins,
	mini_lcd_init_pins,
	configure_L38GM9360_lcd,
	// timing min PCLK=20Mhz, PCD=ACCR[HSS]/PCLK -1
	{
		7,	/* BLW */
		23,	/* ELW */
		7,	/* HSW */
		3,	/* BFW */
		3,	/* EFW */
		1,	/* VSW */
		/* PCD */
		{
			0x3,    /* 104M */
			0x5,    /* 156M */
			0x7,    /* 208M */
			0x0,    /* 39M */
			0x0     /* D0CS */
		}
	},
	{ 
		0,	/* OEP */
		0,	/* PCP */
		1,	/* HSP */
		1	/* VSP */
	}
};

static const XLLP_UINT32_T lcd_mfp_list []={
	XLLP_MFP_L_DD_8_OFFSET,    
	XLLP_MFP_L_DD_9_OFFSET,   
	XLLP_MFP_L_DD_10_OFFSET,   
	XLLP_MFP_L_DD_11_OFFSET,   
	XLLP_MFP_L_DD_12_OFFSET,       
	XLLP_MFP_L_DD_13_OFFSET,       
	XLLP_MFP_L_DD_14_OFFSET,       
	XLLP_MFP_L_DD_15_OFFSET,       
	XLLP_MFP_L_DD_16_OFFSET,       
	XLLP_MFP_L_DD_17_OFFSET,       
	XLLP_MFP_L_DD_0_OFFSET,   
	XLLP_MFP_L_DD_1_OFFSET,   
	XLLP_MFP_L_DD_2_OFFSET,     
	XLLP_MFP_L_DD_3_OFFSET,      
	XLLP_MFP_L_DD_4_OFFSET,      
	XLLP_MFP_L_DD_5_OFFSET,       
	XLLP_MFP_L_DD_6_OFFSET,       
	XLLP_MFP_L_DD_7_OFFSET,      
	XLLP_MFP_L_FCLK_OFFSET,       
	XLLP_MFP_L_LCLK_OFFSET,         
	XLLP_MFP_L_PCLK_OFFSET,       
	XLLP_MFP_L_BIAS_OFFSET,	
	XLLP_MFP_L_LCD_RST_OFFSET,
	       
	XLLP_MFP_PIN_EOLIST_MARKER 
};

static const XLLP_MFP_ALT_FN_T lcd_af_list []={
	XLLP_MFP_L_DD_8_AF, 
	XLLP_MFP_L_DD_9_AF,
	XLLP_MFP_L_DD_10_AF,
	XLLP_MFP_L_DD_11_AF,   
	XLLP_MFP_L_DD_12_AF,   
	XLLP_MFP_L_DD_13_AF,   
	XLLP_MFP_L_DD_14_AF,   
	XLLP_MFP_L_DD_15_AF,   
	XLLP_MFP_L_DD_16_AF,   
	XLLP_MFP_L_DD_17_AF,      
	XLLP_MFP_L_DD_0_AF,   
	XLLP_MFP_L_DD_1_AF,   
	XLLP_MFP_L_DD_2_AF,   
	XLLP_MFP_L_DD_3_AF,   
	XLLP_MFP_L_DD_4_AF,   
	XLLP_MFP_L_DD_5_AF,   
	XLLP_MFP_L_DD_6_AF,   
	XLLP_MFP_L_DD_7_AF,   
	XLLP_MFP_L_FCLK_AF,     
	XLLP_MFP_L_LCLK_AF,   
	XLLP_MFP_L_PCLK_AF,   
	XLLP_MFP_L_BIAS_AF,
	XLLP_MFP_L_LCD_RST_AF
	};

static const XLLP_MFP_ALT_FN_T mini_lcd_af_list []={
	XLLP_MFP_ALT_FN_1, 
	XLLP_MFP_ALT_FN_1,
	XLLP_MFP_ALT_FN_1,
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,      
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,     
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,   
	XLLP_MFP_ALT_FN_1,

	XLLP_MFP_ALT_FN_0			
};

static const XLLP_MFP_DRIVE_STRENGTH_T lcd_ds_list []={
	XLLP_MFP_DS_02X,	//0
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,	
	XLLP_MFP_DS_02X,	//5
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_01X,
	XLLP_MFP_DS_01X,	
	XLLP_MFP_DS_02X,	//10
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,	
	XLLP_MFP_DS_02X,	//15
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_02X,
	XLLP_MFP_DS_01X,
	XLLP_MFP_DS_01X,	
	XLLP_MFP_DS_02X,	//20
	XLLP_MFP_DS_01X,	//21
	XLLP_MFP_DS_01X,	//22	
	XLLP_MFP_DS_01X	//22
};

static XLLP_BOOL_T mfp_resource_managed = 0;

static void set_power_mode(struct XLLP_LCD_S *pXllpLCD, XLLP_UINT32_T power_mode)
{
	
}

static XLLP_STATUS_T init_pins(P_XLLP_LCD_T pXllpLCD)
{
	XLLP_STATUS_T status = 0;
    XLLP_OST_T* pOSTRegs = (XLLP_OST_T *)pXllpLCD->OST;
	P_XLLP_I2C_T pI2CRegs = (XLLP_I2C_T *)pXllpLCD->I2C;

	if (!mfp_resource_managed)
	{
		status =  XllpMfpResourceManager_List(pXllpLCD->pMfpRmDb, 
											  (P_XLLP_UINT32_T)lcd_mfp_list, 
											  XLLP_MFP_RM_ID_XLLP_LCD, 
											  XLLP_SET);

		if ( XLLP_STATUS_SUCCESS != status)
			goto err1;

		mfp_resource_managed = 1;
	}

    // Lock MFPR block until finished with all MFPRs.
    // Don't forget to unlock for early returns, too.
    
	XllpClockEnable((P_XLLP_CLKMGR_T)pXllpLCD->CLKMan, XLLP_CLK_LCD, FALSE);
	// Initialize the MFP registers for proper LCD Controller operation
	status =  XllpMfpSetAfDs_List((P_XLLP_VUINT32_T)(pXllpLCD->MFP), 
								  (P_XLLP_UINT32_T)lcd_mfp_list, 
								  (P_XLLP_MFP_ALT_FN_T)lcd_af_list, 
								  (P_XLLP_MFP_DRIVE_STRENGTH_T)lcd_ds_list);
	if (status != XLLP_STATUS_SUCCESS)
		goto err1;

	status = XllpMfpActivatePullUpDown_List((P_XLLP_VUINT32_T)(pXllpLCD->MFP),
               								(P_XLLP_UINT32_T)lcd_mfp_list,
               								 XLLP_OFF);
	if (status != XLLP_STATUS_SUCCESS)
			goto err1;


    XllpGpioSetDirection((P_XLLP_GPIO_T)pXllpLCD->GPIO, XLLP_GPIO_LCD_RESET_N, XLLP_GPIO_DIRECTION_OUT);
	/*if(XllpI2cInit(pI2CRegs,
			 pXllpLCD->MFP,
			 pXllpLCD->pMfpRmDb, 
			 XLLP_MFP_RM_ID_XLLP_I2C))
	{
		RETAILMSG(1, (_T("I2C Init Fail\r\n")));
	}*/
	if(XllpGpioSetOutputLevel((P_XLLP_GPIO_T)pXllpLCD->GPIO, XLLP_GPIO_LCD_RESET_N, XLLP_HI) != XLLP_STATUS_SUCCESS)
	{
		RETAILMSG(1, (_T("Set XLLP_GPIO_LCD_RESET HI\r\n")));
	}
		XllpOstDelayMilliSeconds(pOSTRegs, 10);
	if(XllpGpioSetOutputLevel((P_XLLP_GPIO_T)pXllpLCD->GPIO, XLLP_GPIO_LCD_RESET_N, XLLP_LO) != XLLP_STATUS_SUCCESS)
	{
		RETAILMSG(1, (_T("Set XLLP_GPIO_LCD_RESET LO\r\n")));
	}	 
	
	XllpOstDelayMilliSeconds(pOSTRegs, 20);
	
	if(XllpGpioSetOutputLevel((P_XLLP_GPIO_T)pXllpLCD->GPIO, XLLP_GPIO_LCD_RESET_N, XLLP_HI) != XLLP_STATUS_SUCCESS)
	{
		RETAILMSG(1, (_T("Set XLLP_GPIO_LCD_RESET HI\r\n")));
	}
err1:
	return status;	    
}

static XLLP_STATUS_T mini_lcd_init_pins(P_XLLP_MINI_LCD_T pXllpMiniLCD, int is_on)
{
	P_XLLP_MFP_ALT_FN_T af_list = (P_XLLP_MFP_ALT_FN_T) (is_on? mini_lcd_af_list : lcd_af_list);
	// Initialize the MFP registers for proper LCD Controller operation
	return XllpMfpSetAfDs_List((P_XLLP_VUINT32_T)(pXllpMiniLCD->MFP), 
	 				    (P_XLLP_UINT32_T)lcd_mfp_list, 
						af_list, 
						(P_XLLP_MFP_DRIVE_STRENGTH_T)lcd_ds_list
						);
}

void lcd_panel_reset(XLLP_SSP_REGISTER_T *ssp)
{
	/* start chucking commands at the lcd */
	XllpSSPCommandLCD(ssp, 0x1); // reset
	XllpSSPCommandLCD(ssp, 0x0); // nop
	XllpSSPCommandLCD(ssp, 0x0); // nop
	XllpSSPCommandLCD(ssp, 0x0); // nop
}

/****************************/
/* VGA pass-through display */
/* D4 D3 D1 D0              */
/*  0  0  0  0              */
/****************************/
void vga_pass_through_mode(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xB0, 0x16);
	XllpSSPCommandLCD_1Para(ssp,  0xBC, 0x80);
	XllpSSPCommandLCD_1Para(ssp,  0xE1, 0x00);
	XllpSSPCommandLCD_1Para(ssp,  0x36, 0x50);
	XllpSSPCommandLCD_1Para(ssp,  0x3B, 0x00);
}

/*****************************/
/* QVGA pass-through display */
/* D4 D3 D1 D0               */
/*  0  0  0  1               */
/*****************************/
void qvga_pass_through_mode(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xB0, 0x16);
	XllpSSPCommandLCD_1Para(ssp,  0xBC, 0x81);
	XllpSSPCommandLCD_1Para(ssp,  0xE1, 0x00);
	XllpSSPCommandLCD_1Para(ssp,  0x36, 0x50);
	XllpSSPCommandLCD_1Para(ssp,  0x3B, 0x22);
}

/*************************************/
/* QVGA RAM display + QVGA RAM write */
/* D4 D3 D1 D0                       */
/*  0  1  1  0                       */
/*************************************/
void qvga_ram_write_mode(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xB0, 0x17);
	XllpSSPCommandLCD_1Para(ssp,  0xBC, 0xAA);
	XllpSSPCommandLCD_1Para(ssp,  0x36, 0xC0);
	XllpSSPCommandLCD_1Para(ssp,  0x3B, 0x22);
	XllpSSPCommandLCD_1Para(ssp,  0xE1, 0x01);
}

void vga_transfer_config(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xcf, 0x02); // Blanking period control (1)
	XllpSSPCommandLCD_2Para(ssp,  0xd0, 0x08, 0x04); // Blanking period control (2)
	XllpSSPCommandLCD_1Para(ssp,  0xd1, 0x01); // CKV timing control on/off
	XllpSSPCommandLCD_2Para(ssp,  0xd2, 0x14, 0x00); // CKV 1,2 timing control
	XllpSSPCommandLCD_2Para(ssp,  0xd3, 0x1a, 0x0f); // OEV timing control
	XllpSSPCommandLCD_2Para(ssp,  0xd4, 0x1f, 0xaf); // ASW timing control (1)
	XllpSSPCommandLCD_1Para(ssp,  0xd5, 0x14); // ASW timing control (2)
	 
	XllpSSPCommandLCD(ssp, 0x21); // Invert for normally black display
	XllpSSPCommandLCD(ssp, 0x29); // Display on
}

void qvga_transfer_config(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xd6, 0x02); // Blanking period control (1)
	XllpSSPCommandLCD_2Para(ssp,  0xd7, 0x08, 0x04); // Blanking period control (2)
	XllpSSPCommandLCD_1Para(ssp,  0xd8, 0x01); // CKV timing control on/off
	XllpSSPCommandLCD_2Para(ssp,  0xd9, 0x00, 0x08); // CKV 1,2 timing control
	XllpSSPCommandLCD_2Para(ssp,  0xde, 0x05, 0x0a); // OEV timing control
	XllpSSPCommandLCD_2Para(ssp,  0xdf, 0x0a, 0x19); // ASW timing control (1)
	XllpSSPCommandLCD_1Para(ssp,  0xe0, 0x0a); // ASW timing control (2)
	 
	XllpSSPCommandLCD(ssp, 0x21); // Invert for normally black display
	XllpSSPCommandLCD(ssp, 0x29); // Display on
}

void qvga_osc_config(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_1Para(ssp,  0xe0, 0x0A);
	XllpSSPCommandLCD_1Para(ssp,  0xe2, 0x00);
	XllpSSPCommandLCD_1Para(ssp,  0xe3, 0x32);
	XllpSSPCommandLCD_2Para(ssp,  0xe4, 0x00, 0x03);
	XllpSSPCommandLCD_2Para(ssp,  0xe5, 0x02, 0x04);
	XllpSSPCommandLCD_1Para(ssp,  0xe6, 0x03);
	XllpSSPCommandLCD_2Para(ssp,  0xe7, 0x04, 0x0A);
	XllpSSPCommandLCD_1Para(ssp,  0xe8, 0x04);
	XllpSSPCommandLCD_1Para(ssp,  0xe9, 0x10);
	XllpSSPCommandLCD_2Para(ssp,  0xea, 0x20, 0x00);
		
	XllpSSPCommandLCD(ssp, 0x21); // Invert for normally black display
	XllpSSPCommandLCD(ssp, 0x29); // Display on
}

void lcd_panel_config(XLLP_SSP_REGISTER_T *ssp)
{
	XllpSSPCommandLCD_2Para(ssp,  0xb8, 0xff, 0xf9); // Output control
	XllpSSPCommandLCD(ssp, 0x11); // sleep out
	XllpSSPCommandLCD_1Para(ssp,  0xba, 0x01); // Display mode (1)
	XllpSSPCommandLCD_1Para(ssp,  0xbb, 0x00); // Display mode (2)
	XllpSSPCommandLCD_1Para(ssp,  0x3a, 0x60); // Display mode 18-bit RGB
	XllpSSPCommandLCD_1Para(ssp,  0xbf, 0x10); // Drive system change control
	XllpSSPCommandLCD_1Para(ssp,  0xb1, 0x56); // Booster operation setup
	XllpSSPCommandLCD_1Para(ssp,  0xb2, 0x33); // Booster mode setup
	XllpSSPCommandLCD_1Para(ssp,  0xb3, 0x11); // Booster frequency setup
	XllpSSPCommandLCD_1Para(ssp,  0xb4, 0x02); // Op amp/system clock
	XllpSSPCommandLCD_1Para(ssp,  0xb5, 0x35); // VCS voltage
	XllpSSPCommandLCD_1Para(ssp,  0xb6, 0x40); // VCOM voltage
	XllpSSPCommandLCD_1Para(ssp,  0xb7, 0x03); // External display signal
	XllpSSPCommandLCD_1Para(ssp,  0xbd, 0x00); // ASW slew rate
	XllpSSPCommandLCD_1Para(ssp,  0xbe, 0x00); // Dummy data for QuadData operation
	XllpSSPCommandLCD_1Para(ssp,  0xc0, 0x11); // Sleep out FR count (A)
	XllpSSPCommandLCD_1Para(ssp,  0xc1, 0x11); // Sleep out FR count (B)
	XllpSSPCommandLCD_1Para(ssp,  0xc2, 0x11); // Sleep out FR count (C)
	XllpSSPCommandLCD_2Para(ssp,  0xc3, 0x20, 0x40); // Sleep out FR count (D)
	XllpSSPCommandLCD_2Para(ssp,  0xc4, 0x60, 0xc0); // Sleep out FR count (E)
	XllpSSPCommandLCD_2Para(ssp,  0xc5, 0x10, 0x20); // Sleep out FR count (F)
	XllpSSPCommandLCD_1Para(ssp,  0xc6, 0xc0); // Sleep out FR count (G)
	XllpSSPCommandLCD_2Para(ssp,  0xc7, 0x33, 0x43); // Gamma 1 fine tuning (1)
	XllpSSPCommandLCD_1Para(ssp,  0xc8, 0x44); // Gamma 1 fine tuning (2)
	XllpSSPCommandLCD_1Para(ssp,  0xc9, 0x33); // Gamma 1 inclination adjustment
	XllpSSPCommandLCD_1Para(ssp,  0xca, 0x00); // Gamma 1 blue offset adjustment
	XllpSSPCommandLCD_2Para(ssp,  0xec, 0x01, 0xf0); // Horizontal clock cycles
}

XLLP_STATUS_T configure_L38GM9360_lcd(struct XLLP_LCD_S* pXllpLCD)
{ 
	XLLP_SSP_REGISTER_T *ssp = (XLLP_SSP_REGISTER_T *) pXllpLCD->SSP;
	XLLP_CLKMGR_T *clkmgr = (XLLP_CLKMGR_T*) pXllpLCD->CLKMan;

/**** mod by litao  at 2008-10-17 ***********************************/
    XLLP_OST_T* pOSTRegs = (XLLP_OST_T *)pXllpLCD->OST;
   // P_XLLP_I2C_T pI2CRegs = (XLLP_I2C_T *)pXllpLCD->I2C;
	    static XLLP_MFP_RM_DB_ID_T g_DB[XLLP_MFP_RM_ID_MAX];
	RETAILMSG(1, (TEXT("+configure_L38GM9360_lcd\r\n")));
	
	// Setup ssp pins 
	XllpSSPMFPConfigure(XLLP_SSP_LT_LCD, XLLP_TRUE, (XLLP_UINT32_T)pXllpLCD->MFP, ssp);

	// clock
	XllpClockEnable(clkmgr, XLLP_CLK_SSP1, XLLP_TRUE);
	// SSP initial
	//XllpSSPPortEnable(ssp, XLLP_FALSE);
	//XllpSSPConfigLCD(ssp, 16);
	//XllpSSPPortEnable(ssp, XLLP_TRUE);
	XllpSSPPortFlush(ssp);  
    XllpOstDelayMilliSeconds(pOSTRegs, 20);
    InitLCD_L38GM9360(ssp,pOSTRegs);
	/************************************************************/

	return XLLP_STATUS_SUCCESS;		
}

void XllpLCDInitTopoly(P_XLLP_LCD_T pXllpLCD, int mode)
{
	/* SSP 2 to configure LCD*/
	p_lcd = pXllpLCD;
	switch(mode)
	{
		case XLLP_LCD_PANEL_ID_L38GM9360:
			pXllpLCD->panel = (lcd_panel_t*)&wvga_L38GM9360_topoly;
			break;
		default:
			pXllpLCD->panel = (lcd_panel_t*)&qvga_topoly;
			break;
	}

	//configure_littleton_lcd(pXllpLCD);

}

void XllpMiniLCDInitTopoly(P_XLLP_MINI_LCD_T lcd)
{
	lcd->panel = &vga_topoly;
}

